<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2018/2/4
 * Time: 下午11:02
 */


$test = "万物皆对象，everything is object";
echo strlen( $test ) . PHP_EOL; //38 = 6*3 = 20
echo mb_strlen( $test ) . PHP_EOL;//26 = 6 + 20
echo mb_strrpos( $test, '对象', 1 ) . PHP_EOL;  // 3
echo mb_strrpos( $test, 'object', 2 ) . PHP_EOL; // 20
echo mb_strrpos( $test, '对象', - 1 ) . PHP_EOL; // 3
echo mb_strrpos( $test, '对象', - mb_strlen( $test ) + 10 ) . PHP_EOL; // 3
echo mb_strrpos( $test, 'object', - 1 ) . PHP_EOL; // 20
echo mb_strrpos( $test, 'object', - 7 ) . PHP_EOL; // false
echo mb_strrpos( $test, '万物皆对象' ) . PHP_EOL; // 0

//运算符优先级！！ 赋值 < 比较
if ( ( $position = mb_strrpos( $test, "万物皆对象" ) ) !== false ) {
	//万物皆对象
	echo mb_substr( $test, $position, 5 ) . PHP_EOL;
}

$str = "https://github.com/zhangrxiang";
if ( ( $position = mb_strrpos( $str, "/" ) ) !== false ) {
	//zhangrxiang
	echo mb_substr( $str, $position + 1 ) . PHP_EOL;
}

$str = "/Users/zhangrongxiang/WorkSpace/phpProjects/PHPTEST/2018/02/04/mb_strrpos.php";
if ( ( $position = mb_strrpos( $str, "/" ) ) !== false ) {
	//mb_strrpos.php
	echo mb_substr( $str, $position + 1 ) . PHP_EOL;
}